MyDesktop.OutStorageRecordWindow = Ext.extend(Ext.app.Module, {
    id:'outRecord-win',
    init : function(){
        this.launcher = {
            text: '出库记录',
            iconCls:'icon-grid',
            handler : this.createWindow,
            scope: this
        }
    },

	record : Ext.data.Record.create([
        	{name : 'docID',mapping : 'docID',type : 'string'}, 
        	{name : 'createMan',mapping : 'createMan',type : 'string'}
	]),
	
    createWindow : function(){
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('outRecord-win');
		
        if(!win){
		
		var store=new Ext.data.Store({
        	url : app.url+'/admin/strorage/outRecord.do',
			baseParams:{start:0,limit:20},
        	reader : new Ext.data.JsonReader({totalProperty : 'totalProperty',root : 'root'}, 
        	this.record)
        });
		
		var stockFind=function() {
            if(find_form.getForm().isValid())
            {
                find_form.form.submit({
                    waitMsg : '正在查寻......',
                    url : app.url+'/admin/strorage/outRecord.do',
					params :{limit:20},
					method:'POST',
                    timeout: 3000,
                    success : function(form, action) {
                     store.loadData(action.result);
                    },
                    failure : function(form, action) {
                        store.loadData(action.result);
                    }
                });
            }
        };	

	var tb =new Ext.Toolbar({
        height: 35,
		region: 'north',
        items: [{
        	 xtype: 'button',
             text: '新增',
			 iconCls: 'add',
			 scale: 'small',
			 handler: function(){
				     //addInstall_win.show();
				}
           
            },'-',{
        	 xtype: 'button',
             text: '审核'
           
          }]
     });
		
        var find_form = new Ext.FormPanel({
            	border : true,
				region: 'north',
				collapsible: true,
                labelAlign : 'right',
                labelWidth : 60,
				frame : true,
				height: 100,
            	items : [{
									layout:'column',
									items:[{
        								columnWidth : .3,
        								layout : 'form',
        								items : [getStorageCombo(true)]
								    },{
        								columnWidth : .2,
        								layout : 'form',
        								items : [getEmployeeCombo('经手人',true)]
								    },{
        								columnWidth : .25,
        								layout : 'form',
        								items : [{xtype : 'textfield',fieldLabel : '出库单号',name : 'buyDate',anchor : '100%'}]
								    },{
        								columnWidth : .25,
        								layout : 'form',
        								items : [{xtype : 'textfield',fieldLabel : '商品单号',name : 'buyDate',anchor : '100%'}]
								    }]
							},{
							   layout:'column',
							   items:[{
        							columnWidth : .25,
        							layout : 'form',
        							items : [{xtype : 'datefield',fieldLabel : '开始日期',name : 'buyDate',anchor : '100%',format:'Y-m-d'}]
							   },{
        							columnWidth : .25,
        							layout : 'form',
        							items : [{xtype : 'datefield',fieldLabel : '结束日期',name : 'buyDate',anchor : '100%',format:'Y-m-d'}]
							   },{  
							        columnWidth : .25,
        							layout : 'form',
        							items : [{
									      xtype : 'button',
										  text : '查询',
										  handler : stockFind
										  }]
							   },{
							        columnWidth : .25,
        							layout : 'form',
        							items : [{xtype : 'button',text : '清空'}]
							   }]
							}]
						});
		

	
	 var cm=new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), 
		 {header: '出库单号',dataIndex: 'docID'},
		 {header : '发生日期',width : 120,dataIndex : 'createMan'},
		 {header : '品牌名称',width : 120,dataIndex : 'createMan'},
		 {header : '商品编号',width : 90,dataIndex : 'createMan'},
		 {header : '单价',width : 80,dataIndex : 'createMan'},
		 {header : '单位',width : 60,dataIndex : 'createMan'},
		 {header : '数量',width : 90,dataIndex : 'createMan'},
		 {header : '金额',width : 90,dataIndex : 'closedate'},
		 {header : '出库人',width : 90,dataIndex : 'createMan'},
		 {header : '申领人',width : 80,dataIndex : 'createMan'},
		 {header : '审核人',width : 60,dataIndex : 'createMan'}
	 ]);
		
	   var grid_debit = new Ext.grid.GridPanel({
        	title : '出库数据',
        	iconCls : 'icon-grid',
			region: 'center',
        	collapsible: false,
			border:false,
            margins: '5 0 0 0',
			columnLines :true,
			autoScroll : true,
			width : 600,
			enableHdMenu : false,
        	viewConfig:
        	{
        	 forceFit:false,
        	 scrollOffset:15
        	 },	   	   
        	autoWidth : true,
        	cm : cm,
        	ds : store,
        	sm : new Ext.grid.CheckboxSelectionModel({singleSelect : false}),
        	enableColumnMove : false,
        	trackMouseOver : false,
        	frame : true,
			bbar : new Ext.PagingToolbar({
        		pageSize: 20,
                store: store,
                displayInfo: true,
                 plugins: new Ext.ux.ProgressBarPager(),
        		items:[{   
                        text: '导出到Excel',   
                        tooltip: 'Excel'
                      }]
        	})
        	
        });	
		
	var p_debit = {
            layout: 'border',
            bodyBorder: false,
            defaults: {
                split: true,
                animFloat: false,
                autoHide: false,
                useSplitTips: true,
        		margins: '5 0 0 0',
                cmargins: '5 5 0 0'
            },
            items: [find_form,grid_debit]
        };	
		
	var vp = new Ext.Panel({
				region: 'center',
                deferredRender: false,
				layout : 'card',
				border : false,
                activeItem : 0,
				items : [p_debit]
			
        });
		
            win = desktop.createWindow({
                id: 'outRecord-win',
                title:'出库记录',
                width:1000,
                height:530,
                iconCls: 'icon-grid',
                shim:false,
                animCollapse:false,
                constrainHeader:true,
                layout: 'border',
                items:[tb,vp]
            });
        }
        win.show();
    }
});